package cn.com.dealme.nutz.view;

import java.util.HashMap;
import java.util.Map;

import org.nutz.json.Json;
import org.nutz.json.JsonFormat;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.View;
import org.nutz.mvc.view.UTF8JsonView;

import cn.com.dealme.Keys;

public class DJsonView extends UTF8JsonView {
	
	private static final Log log = Logs.getLog(UTF8JsonView.class);
	
	public DJsonView(JsonFormat format) {
		super(format);
	}

	public DJsonView(JsonFormat format, Object data) {
		this(format);
		super.setData(data);
		if(log.isDebugEnabled()) {
			log.debug("write json: " + Json.toJson(data, JsonFormat.compact()));
		}
	}
	
	public DJsonView(Object data) {
		this(JsonFormat.compact(), data);
	}
	
	public static View createExtSuccessView() {
		Map<String, String> map = new HashMap<String, String>();
		map.put(Keys.Success, Boolean.TRUE.toString());
		return new DJsonView(JsonFormat.compact(), map);
	}
	

	
}
